package com.lyn.module_custom_utils;

import com.alibaba.fastjson.JSONArray;

import java.util.HashSet;
import java.util.Iterator;
/**
 * @author:longyongning
 * @date:2021/10/2
 * @description: JSON处理工具
 */
public class JSONUtil {

    /**
     * 去重
     * @param jsonArray
     * @return
     */
    public static JSONArray deDuplication(JSONArray jsonArray) {
        HashSet<Object> objectHashSet = new HashSet<>();
        objectHashSet.addAll(jsonArray);
        Iterator<Object> iterator = objectHashSet.iterator();
        JSONArray resultJSONArray = new JSONArray();
        while (iterator.hasNext()) {
            Object object = iterator.next();
            resultJSONArray.add(object);
        }
        return resultJSONArray;
    }
}
